package com.bjkcst.baselib.utils;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * @author: glc.
 * Date: 2023/1/9  18:07
 * Description:
 */
public class AutoStartBroadcastReceiver extends BroadcastReceiver {

    private static final String ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
    private static final String INTENT_ACTION = "android.intent.action.KCST_AUTO_START";

    @Override
    public void onReceive(Context context, Intent intent) {
        if (intent == null || context == null){return;}
        if (intent.getAction().equals(ACTION_BOOT_COMPLETED)){
            Intent sIntent = new Intent();
            sIntent.setAction(INTENT_ACTION);
            sIntent.addCategory(Intent.CATEGORY_DEFAULT);
            sIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(sIntent);

        }
    }
}
